package gmodel

import (
	"gorm.io/gorm"
)

type IDb interface {
	IBase

	//基类实现
	//SetClient(c *corm.Client)
	//Client(name ...string) *corm.Client
	Db() *gorm.DB

	//是否hash分表
	IsHash() bool

	//实体类实现
	TableName() string

	//基类实现
	DbGet(child IDb, wheres ...any) (err error)
	DbFirst(child IDb, orderBy string, wheres ...any) (err error)
	DbPage(child IDb, list any, keys, join, order string, page, limit int, wheres ...any) (count int64, err error)
	DbPageAK(child IDb, list any, join, order string, page, limit int, wheres ...any) (count int64, err error)
	DbAdd(child IDb) (err error)
	DbUpdate(child IDb, keys ...string) (err error)
	DbSave(child IDb) (err error)
	DbDel(child IDb) (err error)
	DbExist(child IDb, wheres ...any) bool
	DbSum(child IDb, sumField string, join string, wheres ...any) (num float64, err error)
	DbSums(child IDb, result any, sumFields string, join string, wheres ...any) (err error)

	//Dao() *Dao             //[基类默认实现]
	//IsHash() bool          //[基类默认实现] 是否分表
	//HashTableName() string //[基类默认实现] 该方法仅供hash分表使用,未分表的模型,默认返回TableName()

	//DbPageAllFld(child IDb, order string, page, limit int, params ...interface{}) ([]orm.Params, int, error)

}
